{% extends 'base.html' %}
{% load static %}

{% block title %}启动盘点计划 - {{ plan.name }}{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0"><i class="fas fa-play me-2"></i>启动盘点计划</h5>
                </div>
                
                <div class="card-body">
                    <div class="alert alert-info">
                        <h6><i class="fas fa-info-circle me-2"></i>确认启动盘点计划</h6>
                        <p class="mb-0">您即将启动盘点计划 <strong>"{{ plan.name }}"</strong>，启动后将无法修改计划配置。</p>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <h6 class="mb-3">计划信息</h6>
                            <table class="table table-borderless table-sm">
                                <tr>
                                    <td width="120"><strong>计划名称：</strong></td>
                                    <td>{{ plan.name }}</td>
                                </tr>
                                <tr>
                                    <td><strong>盘点类型：</strong></td>
                                    <td><span class="badge bg-info">{{ plan.get_plan_type_display }}</span></td>
                                </tr>
                                <tr>
                                    <td><strong>计划时间：</strong></td>
                                    <td>{{ plan.planned_start_date|date:"Y-m-d H:i" }} ~ {{ plan.planned_end_date|date:"Y-m-d H:i" }}</td>
                                </tr>
                                <tr>
                                    <td><strong>资产数量：</strong></td>
                                    <td><span class="badge bg-primary">{{ plan.total_assets_count }}</span> 个</td>
                                </tr>
                            </table>
                        </div>
                        
                        <div class="col-md-6">
                            <h6 class="mb-3">盘点范围</h6>
                            <div class="mb-3">
                                {% if plan.departments.exists %}
                                    <strong>部门：</strong>
                                    {% for dept in plan.departments.all %}
                                        <span class="badge bg-light text-dark me-1">{{ dept.name }}</span>
                                    {% endfor %}
                                    <br>
                                {% endif %}
                                
                                {% if plan.categories.exists %}
                                    <strong>类别：</strong>
                                    {% for cat in plan.categories.all %}
                                        <span class="badge bg-light text-dark me-1">{{ cat.name }}</span>
                                    {% endfor %}
                                    <br>
                                {% endif %}
                                
                                {% if plan.locations.exists %}
                                    <strong>位置：</strong>
                                    {% for loc in plan.locations.all %}
                                        <span class="badge bg-light text-dark me-1">{{ loc.name }}</span>
                                    {% endfor %}
                                    <br>
                                {% endif %}
                                
                                {% if not plan.departments.exists and not plan.categories.exists and not plan.locations.exists %}
                                    <span class="text-muted">全部资产</span>
                                {% endif %}
                            </div>
                            
                            <h6 class="mb-3">盘点人员</h6>
                            {% for assignee in plan.assignees.all %}
                                <span class="badge bg-success me-1">{{ assignee.get_full_name|default:assignee.username }}</span>
                            {% empty %}
                                <span class="text-muted">未分配具体人员</span>
                            {% endfor %}
                        </div>
                    </div>
                    
                    {% if plan.description %}
                        <div class="mt-4">
                            <h6>计划描述</h6>
                            <p class="text-muted">{{ plan.description }}</p>
                        </div>
                    {% endif %}
                    
                    <div class="alert alert-warning mt-4">
                        <h6><i class="fas fa-exclamation-triangle me-2"></i>注意事项</h6>
                        <ul class="mb-0">
                            <li>启动后计划状态将变为"进行中"，无法再修改计划配置</li>
                            <li>系统将自动记录实际开始时间</li>
                            <li>盘点人员可以开始对资产进行盘点操作</li>
                            <li>建议在启动前确认所有盘点人员已做好准备</li>
                        </ul>
                    </div>
                    
                    <form method="post" class="mt-4">
                        {% csrf_token %}
                        <div class="d-flex justify-content-between">
                            <a href="{% url 'assets:inventory_plan_detail' plan.pk %}" class="btn btn-secondary">
                                <i class="fas fa-arrow-left me-1"></i>返回详情
                            </a>
                            <div>
                                <button type="button" class="btn btn-outline-danger me-2" onclick="history.back()">
                                    <i class="fas fa-times me-1"></i>取消
                                </button>
                                <button type="submit" class="btn btn-success" onclick="return confirm('确定要启动此盘点计划吗？')">
                                    <i class="fas fa-play me-1"></i>确认启动
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
